//
//  BaseTableBC.swift
//  我的微博
//
//  Created by shmily on 15/7/28.
//  Copyright © 2015年 Stanford-IOS8-Swift-shmilyAshen. All rights reserved.
//

import UIKit

class BaseTableVC: UITableViewController,VisitorViewDelegate{

    
    ///设置登陆状态
    var isLogon: Bool = UserInfo.isLogon
    
    //访客视图
    var visitorView : VisitorView?
    
    //如果是访客模式,则加载新的视图控制器
    override func loadView() {
        isLogon ? super.loadView() : loadVistorView()
    }
    
    
    //MARK:- 访客视图
    private func loadVistorView() {
        visitorView = VisitorView()
        
        visitorView?.delegate = self
        view = visitorView!
        
        //添加导航控制器
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Done, target: self, action: "visitorViewRegistor")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Done, target: self, action: "visitorViewLogin")
    }
    
    func visitorViewRegistor() {
        print("注册")
    }
    
    func visitorViewLogin() {
        
        //modal OAuth控制器
        let nav = UINavigationController(rootViewController: OAuth())
        presentViewController(nav, animated: true) { () -> Void in
            
        }
    }

}
